#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.61)
AC_INIT(otfeed-examples, 0.0.3, crayzeewulf@gmail.com)
AC_CONFIG_SRCDIR([src/otfeed_test.cpp])
AC_CONFIG_HEADER([config.h])
AM_INIT_AUTOMAKE()

# Checks for programs.
AC_PROG_CXX
AC_PROG_CC

# 
# Use C++ for compiling test programs during configuration.
#
AC_LANG(C++)


# ----------------------------------------------------------------------------
# Provide a mechanism for users to specify the location of the OTFeed
# installation.
#
OTFEEDDIR=
AC_ARG_WITH( [otfeed],
             [AS_HELP_STRING( [--with-otfeed],
                              [path to otfeed installation])],
             [OTFEEDDIR=$withval] )
#
if ! test -z "$OTFEEDDIR"; then
	CPPFLAGS="$CPPFLAGS -I$OTFEEDDIR/include"
	LDFLAGS="$LDFLAGS -L$OTFEEDDIR/lib"
fi
# ----------------------------------------------------------------------------
# Provide a mechanism for users to specify the location of the Boost
# installation.
#
BOOSTDIR=
AC_ARG_WITH( [boost],
             [AS_HELP_STRING( [--with-boost],
                              [path to Boost installation])],
             [BOOSTDIR=$withval] )
#
if ! test -z "$BOOSTDIR"; then
    CPPFLAGS="$CPPFLAGS -I$BOOSTDIR/include"
    LDFLAGS="$LDFLAGS -L$BOOSTDIR/lib"
fi
# ----------------------------------------------------------------------------


# Checks for libraries.
# FIXME: Replace `main' with a function in `-lOTFeed':
AC_CHECK_LIB( [OTFeed], 
              [main], 
              [], 
              AC_MSG_ERROR(Could not find OTFeed library.) )

# FIXME: Replace `main' with a function in `-lpthread':
AC_CHECK_LIB( [pthread], 
              [main], 
              [], 
              AC_MSG_ERROR(Could not find pthread library.) )

# Checks for header files.
AC_CHECK_HEADERS([unistd.h])

#
# Check for header files that are required to compile the source code.
#
AC_CHECK_HEADER( [boost/bind.hpp],
                 [],
                 AC_MSG_ERROR( Could not find "boost/bind.hpp" ) 
                 )
                 
# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_CONST
AC_C_INLINE
AC_STRUCT_TM

# Checks for library functions.
AC_FUNC_MKTIME
AC_CHECK_FUNCS([getpass])

AC_CONFIG_FILES( [ Makefile 
                   src/Makefile ] )
AC_OUTPUT
